package com.heima.utils.common;

public class UserContext {
    private static final ThreadLocal<Long> THREAD_LOCAL = new ThreadLocal<>();
/**
 *ThreadLocal存数据
 */
 public static void setUserId(Long userId){
     THREAD_LOCAL.set(userId);
 }
/**
 *ThreadLocal取数据
 */
public static Long getUserId(){
  return   THREAD_LOCAL.get();
}

    /**
     * 向threadlocal删除数据
     */
    public static void removeUserId() {
        THREAD_LOCAL.remove();
    }
}